var connection = require("../mysqldb");

// 查询hhpwuser表  用于登录

class selectSql {
  constructor() { }
  init(res, data) {
    console.log("执行了Select")
    var sql = "SELECT * FROM hhpwuser WHERE user = '" + data.user + "' and password='" + data.password + "'";
    connection.query(sql, function (err, result) {
      if (err) {
        console.log('[SELECT ERROR] - ', err.message);
        return;
      } else {

        var jsonserver = {
          "msg": result.length ? "登录成功" : "登录失败",
          "result": result,
          "code": result.length ? "1" : "0",
        }
        res.write("");
        res.end(JSON.stringify(jsonserver));

        // res.write(JSON.stringify(jsonserver));
        // res.end();

      }

    })
    // console.log(data);
  }


}

module.exports = new selectSql;